<template>
    <view class="pub_page pub_mine_index pub_tabbar_padding">
        <pub-head :headerConfig="headerConfig" @headerBack="headerBack"></pub-head>
        <pub-tabbar :active="4"></pub-tabbar>
        <div class="page_box" v-if="userInfo!=''">
            <div class="user_div" @click="$comFun.openWin('/pages/mine/info')">
                <pub-image class="headimg" :src="userInfo.avatar" :mode="'aspectFill'"></pub-image>
                <div class="text">
                    <div class="name">
                        <div class="span">{{ userInfo.nickName }}</div>
                        <div class="span_1" v-if="userInfo.grade==0">{{ $constant.specialGradeInfo[userInfo.specialGrade] }}</div>
                        <div class="span_1" v-else>{{ $constant.gradeInfo[userInfo.grade] }}</div>
                        <div class="span_2" v-if="userInfo.manageGrade>0">{{ $constant.manageGradeInfo[userInfo.manageGrade] }}</div>
                    </div>
                    <div class="id">
                        {{ $comFun.replaceMobile(userInfo.mobile) }}
                        <span class="span">邀请码：{{ userInfo.invitationCode }}</span>
                        <span class="span" @click.stop="$comFun.toCopy(userInfo.invitationCode)">复制</span>
                    </div>
                </div>
            </div>
            <div class="nums_div">
                <div class="title">我的钱包
                    <div class="more" @click="$comFun.openWin('/pages/mine/wallet')">进入钱包 ></div>
                </div>
                <div class="num">
                    <div class="li" @click="$comFun.openWin('/pages/mine/log',{openType:1})">
                        <div class="p_1">{{ userInfo.consumeTicket }}</div>
                        <div class="p_2">旺票</div>
                    </div>
                    <div class="li" @click="$comFun.openWin('/pages/mine/log',{openType:2})">
                        <div class="p_1">{{ userInfo.increment }}</div>
                        <div class="p_2">幸运值</div>
                    </div>
                    <div class="li" @click="$comFun.openWin('/pages/mine/log',{openType:3})">
                        <div class="p_1">{{ userInfo.exchangeTicket }}</div>
                        <div class="p_2">兑换券</div>
                    </div>
                </div>
            </div>
            <!-- <div class="img_div" @click="jxsClick">
                <pub-image class="img" :src="'../../static/aimg/img_21.png'" :mode="'widthFix'"></pub-image>
            </div> -->
            <br>
            <div class="img_div" @click="jysClick">
                <pub-image class="img" :src="'../../static/aimg/img_65.png'" :mode="'widthFix'"></pub-image>
            </div>
            <div class="tools_div">
                <div class="title">我的服务</div>
                <div class="lis">
                    <div class="li" @click="$comFun.openWin('/pages/other/address',{openType:1})">
                        <pub-image class="img" :src="'../../static/aimg/img_9.png'"></pub-image>
                        <div class="txt">收货地址</div>
                    </div>
                    <div class="li" @click="$comFun.openWin('/pages/mine/realname')">
                        <pub-image class="img" :src="'../../static/aimg/img_10.png'"></pub-image>
                        <div class="txt">实名认证</div>
                    </div>
                    <div class="li" @click="$comFun.openWin('/pages/mine/team')">
                        <pub-image class="img" :src="'../../static/aimg/img_11.png'"></pub-image>
                        <div class="txt">团队管理</div>
                    </div>
                    <div class="li" @click="$comFun.openWin('/pages/mine/invite',{invitationCode:userInfo.invitationCode})">
                        <pub-image class="img" :src="'../../static/aimg/img_12.png'"></pub-image>
                        <div class="txt">邀请有礼</div>
                    </div>
                    <div class="li" @click="$comFun.toast('敬请期待')">
                        <pub-image class="img" :src="'../../static/aimg/img_13.png'"></pub-image>
                        <div class="txt">客服中心</div>
                    </div>
                    <div class="li" @click="$comFun.toast('敬请期待')">
                        <pub-image class="img" :src="'../../static/aimg/img_14.png'"></pub-image>
                        <div class="txt">商户入驻</div>
                    </div>
                    <div v-if="userInfo.grade>0" class="li" @click="$comFun.openWin('/pages/mine/service')">
                        <pub-image class="img" :src="'../../static/aimg/img_15.png'"></pub-image>
                        <div class="txt">业务管理</div>
                    </div>
                    <div class="li" @click="$comFun.openWin('/pages/other/notice')">
                        <pub-image class="img" :src="'../../static/aimg/img_16.png'"></pub-image>
                        <div class="txt">公告中心</div>
                    </div>
                    <div class="li" @click="$comFun.openWin(userInfo.account?'/pages/mine/trade':'/pages/mine/bind_account')">
                        <pub-image class="img" :src="'../../static/aimg/img_64.png'"></pub-image>
                        <div class="txt">交易中心</div>
                    </div>
                </div>
            </div>
        </div>
    </view>
</template>

<script>
export default {
    data() {
        return {
            headerConfig: {
                title: '我的',//标题栏内容
                header_color: '',
                right_type: 2,//右侧区域类型  0不出现  1文字  2图片
                right_content: '../../static/aimg/img_46.png',//右侧内容  right_type为1时文字内容 为2时图片链接
            },
            userInfo: '',

            mqModule: '',
        };
    },
    onLoad() {
        // #ifdef APP-PLUS
        // this.mqModule = uni.requireNativePlugin("MeiQia-ChatPlugin");
        // #endif
    },
    onShow() {
        this.getInfo();
    },
    methods: {
        headerBack(data) {
            if (data.type == 'right') {
                this.$comFun.openWin('/pages/other/set');
            }
        },
        openMeiQia() {
            this.mqModule.initChatViewManger();
            this.mqModule.setLoginCustomizedId(this.userInfo.mobile);
            this.mqModule.configChatViewStyle({
                "navBarBackgroundColor": "#1661F6", // 设置导航栏的背景色；
                "navBarTitleTxtColor": "#ffffff", // 设置导航栏上的 title 的颜色；
                "enableShowClientAvatar": true, // 是否支持当前用户头像的显示
            });
            this.mqModule.showMeiQiaChatView();
        },
        async getInfo() {
            if (this.userInfo == '') {
                this.$comFun.openLoading();
            }
            const res = await this.$request.get('user/userInfo', {});
            if (this.userInfo == '') {
                this.$comFun.closeLoading();
            }
            // console.log(res);
            if (res.code == 200) {
                this.userInfo = res.result;
            }
        },
        jxsClick() {
            if (this.userInfo.grade == 0) {
                this.$comFun.openWin('/pages/index/good_info', { orderType: 4 })
            }
        },
        jysClick(){
            // #ifdef APP-PLUS
            plus.runtime.openURL('https://yw.ceramic-copyright.com/mobile/#/register/31941191');
            // #endif
        }
    },
};
</script>

<style lang="scss" scoped>
@import "@/common/css/mine.scss";
</style>
